<?php
namespace Amis\form;
class Select extends FormItem
{
    public string $type = 'nested-select';

    /**
     * @param array $options
     * @return $this
     */
    public function options(array $options)
    {
        $this->options = $options;
        return $this;
    }

    /**
     * @param string $source
     * @return $this
     */
    public function source(string $source)
    {
        $this->source = $source;
        return $this;
    }

    /**
     * @param bool $delimiter
     * @return $this
     */
    public function delimiter(bool $delimiter = false)
    {
        $this->delimiter = $delimiter;
        return $this;
    }

    public function labelField(string $labelField)
    {
        $this->labelField = $labelField;
        return $this;
    }

    public function valueField(string $valueField)
    {
        $this->valueField = $valueField;
        return $this;
    }

    public function joinValues(bool $joinValues = true)
    {
        $this->joinValues = $joinValues;
        return $this;
    }

    public function extractValue(bool $extractValue = false)
    {
        $this->extractValue = $extractValue;
        return $this;
    }

    public function autoFill(array $autoFill)
    {
        $this->autoFill = $autoFill;
        return $this;
    }

    /**
     * 设置 true时，当选中父节点时不自动选择子节点。
     * @param bool $cascade
     * @return $this
     */
    public function cascade(bool $cascade = false)
    {
        $this->cascade = $cascade;
        return $this;
    }

    /**
     * 设置 true时，选中父节点时，值里面将包含子节点的值，否则只会保留父节点的值。
     * @param bool $withChildren
     * @return $this
     */
    public function withChildren(bool $withChildren = false)
    {
        $this->withChildren = $withChildren;
        return $this;
    }

    /**
     * 多选时，选中父节点时，是否只将其子节点加入到值中。
     * @param bool $onlyChildren
     * @return $this
     */
    public function onlyChildren(bool $onlyChildren = false)
    {
        $this->onlyChildren = $onlyChildren;
        return $this;
    }

    /**
     * 可否搜索
     * @param bool $searchable
     * @return $this
     */
    public function searchable(bool $searchable = false)
    {
        $this->searchable = $searchable;
        return $this;
    }

    /**
     * 搜索框占位文本
     * @param bool $searchPromptText
     * @return $this
     */
    public function searchPromptText(string $searchPromptText = '输入内容进行检索')
    {
        $this->searchPromptText = $searchPromptText;
        return $this;
    }

    /**
     * 无结果时的文本
     * @param string $noResultsText
     * @return $this
     */
    public function noResultsText(string $noResultsText = '未找到任何结果')
    {
        $this->noResultsText = $noResultsText;
        return $this;
    }

    /**
     * 可否多选
     * @param bool $multiple
     * @return $this
     */
    public function multiple(bool $multiple = false)
    {
        $this->multiple = $multiple;
        return $this;
    }

    /**
     * 是否隐藏选择框中已选择节点的路径 label 信息
     * @param bool $hideNodePathLabel
     * @return $this
     */
    public function hideNodePathLabel(bool $hideNodePathLabel = false)
    {
        $this->hideNodePathLabel = $hideNodePathLabel;
        return $this;
    }

    /**
     * 只允许选择叶子节点
     * @param bool $onlyLeaf
     * @return $this
     */
    public function onlyLeaf(bool $onlyLeaf = false)
    {
        $this->onlyLeaf = $onlyLeaf;
        return $this;
    }
}